package com.gupao.javavip.gof.factorypattern.factory.simplefactory;

import com.gupao.javavip.gof.factorypattern.product.BeerWine;
import com.gupao.javavip.gof.factorypattern.product.IWine;
import com.gupao.javavip.gof.factorypattern.product.MaotaiWine;
import com.gupao.javavip.gof.factorypattern.product.WuliangyeWine;

public class SimpleWineFactory {

    public static void drink(String name) {
        IWine wine = null;

        if ("wuliangye".equalsIgnoreCase(name)) {
            wine = new WuliangyeWine();
        } else if ("maotai".equalsIgnoreCase(name)) {
            wine = new MaotaiWine();
        } else if ("beer".equalsIgnoreCase(name)) {
            wine = new BeerWine();
        } else {
            throw new IllegalArgumentException("没有这种酒");
        }

        wine.intoxicate();
    }
}
